<!DOCTYPE html>
<title>Test loading video twice.</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<body>
<script>
async_test(function(t) {
    var file = "http://127.0.0.1:8000/resources/test.ogv";
    createAndLoadVideo(false);
    function createAndLoadVideo(endTest) {
        var video = document.createElement("video");
        document.body.appendChild(video);
        var expectedEvents = ["loadedmetadata", "loadeddata", "canplay", "canplaythrough"];
        var watcher = new EventWatcher(t, video, expectedEvents);
        watcher.wait_for(expectedEvents).then(t.step_func(function() {
            if (endTest) {
                t.done();
            }  else {
                document.body.removeChild(video);
                createAndLoadVideo(true);
            }
        }));

        video.src = file;
    }
});
</script>